#encoding=utf-8
from MysqlHelper import *
from hashlib import sha1#引入用于sha1加密所需要的库
sname = raw_input("请输入用户名：")
spwd  = raw_input('请输入密码：')

s1 = sha1()#实例化sha1加密对象
s1.update(spwd)#将明文密码转化我isha1加密后的密码
spwdSha1 = s1.hexdigest()#用十六进制表示加密密码

sql = 'select upwd from userinfos where uname=%s'
params = [sname]
sqlhelper = MysqlHelper('localhost',3306,'test1','root','1')
userinfo = sqlhelper.get_one(sql,params)
if userinfo == None:
    print '用户名错误'
elif userinfo[0] == spwdSha1:
    print '登陆成功'
else:
    print '密码错误'